Skip to content

Conversation

@Uanela
Copy link

@Uanela Uanela commented Dec 9, 2025

Refactored the dir-up action by moving it from a standalone module into the Explorer class as a method. This improves code organization by consolidating explorer-related functionality within the Explorer class itself.

Changes

  • Deleted lua/nvim-tree/actions/root/dir-up.lua
  • Modified lua/nvim-tree/actions/root/init.lua - Removed dir_up require statement
  • Modified lua/nvim-tree/api.lua - Updated Api.tree.change_root_to_parent to call the new Explorer method via wrap_explorer("dir_up")
  • Modified lua/nvim-tree/explorer/init.lua - Added Explorer:dir_up(node) method

@alex-courtis
Copy link
Member

Thanks @Uanela I will get to a review on the weekend.

What sort of task would you like to work on next? Another refactor? Bug? Feature?

@Uanela
Copy link
Author

Uanela commented Dec 10, 2025

I guess a another refactor would help me still getting along with the codebase.

@alex-courtis
Copy link
Member

Base Cases OK

Open /home/alex/src/keyd

:NvimTreeOpen

<C-]> data
:pwd
/home/alex/src/keyd/data

-
:pwd
/home/alex/src/keyd

-
:pwd
/home/alex/src

respect_buf_cwd = true OK

Open /home/alex/src/keyd

:NvimTreeOpen

-

q

:NvimTreeOpen

Above Tests Repeated On Node And Root

OK

Copy link
Member

@alex-courtis alex-courtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good @Uanela , all tests pass and it's working beautifully.

Only one small change please:


local newdir = vim.fn.fnamemodify(utils.path_remove_trailing(cwd), ":h")
require("nvim-tree.actions.root.change-dir").fn(newdir)
require("nvim-tree.actions.finders.find-file").fn(node.absolute_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move these requires up to the top of the file. Here's an example you can follow: https://github.com/nvim-tree/nvim-tree.lua/blob/master/lua/nvim-tree/actions/tree/open.lua#L3

Why do this at the start of the file?

  • We only want to do it once, for speed
  • Any problems with the require are found immediately at startup, instead of later at runtime

@alex-courtis
Copy link
Member

I guess a another refactor would help me still getting along with the codebase.

I'll get back to you shortly. The issue backlog needs to be groomed and tidied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants